from selenium.webdriver.common.by import By
from base.page_base import BasePage
from config import NAME, CARD


class OpenAccount(BasePage):
    """元素定位信息"""
    click_op=(By.LINK_TEXT, "立即开通")
    readline=(By.NAME, "realname")
    card_id=(By.NAME, "card_id")
    Confirm=(By.CSS_SELECTOR, '[value="确认提交"]')
    imm_open=(By.CSS_SELECTOR, '.btn.ng-scope')
    gain_text=(By.CSS_SELECTOR, "body")

    def click_open(self):
        """点击开通按钮"""
        self.base_click(self.click_op)
    def input_readline(self,readline):
        """输入姓名"""
        self.base_input(self.readline,readline)
    def input_card_id(self,card_id):
        """输入身份证"""
        self.base_input(self.card_id,card_id)
    def click_confirm(self):
        """点击提交"""
        self.base_click(self.Confirm)
    def click_imm_open(self):
        """点击立即开通"""
        self.base_click(self.imm_open)
    def get_open_success_text(self):
        return self.fd_element(self.gain_text).text
    def get_result_text(self):
        return self.base_switch_handle(self.gain_text).text
    def full_open(self,readline=NAME,card_id=CARD):
        self.click_open()
        self.input_readline(readline)
        self.input_card_id(card_id)
        self.click_confirm()
        self.click_imm_open()



